package cn.wolfcode.service.impl;

import cn.wolfcode.domain.MessageReplyZrh;
import cn.wolfcode.mapper.MessageReplyZrhMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IMessageReplyZrhService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageReplyZrhServiceImpl implements IMessageReplyZrhService {

    @Autowired
    private MessageReplyZrhMapper messageReplyZrhMapper;


    @Override
    public void save(MessageReplyZrh messageReplyZrh) {
        messageReplyZrhMapper.insert(messageReplyZrh);
    }

    @Override
    public void delete(Long id) {
        messageReplyZrhMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(MessageReplyZrh messageReplyZrh) {
        messageReplyZrhMapper.updateByPrimaryKey(messageReplyZrh);
    }

    @Override
    public MessageReplyZrh get(Long id) {
        return messageReplyZrhMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<MessageReplyZrh> listAll() {
        return messageReplyZrhMapper.selectAll();
    }

    @Override
    public PageInfo<MessageReplyZrh> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<MessageReplyZrh> messageReplyZrhs = messageReplyZrhMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<MessageReplyZrh>(messageReplyZrhs);
    }

    @Override
    public List<MessageReplyZrh> selectByBoardId(Long id) {
        return messageReplyZrhMapper.selectByBoardId(id);
    }
}
